home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4932 < prev    next >
Encoding:
Text File  |  1996-08-06  |  9.5 KB  |  248 lines

  1. Path: interramp.com!usenet
  2. From: Barnett@interramp.com (Barnett E. Kurtz)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Old Fortran dog learning new Visual C++ tricks - some questions
  5. Date: Thu, 01 Feb 1996 18:02:46 GMT
  6. Organization: EntroData, Inc.
  7. Message-ID: <4eqvap$j82@usenet2.interramp.com>
  8. References: <4en04g$5nv@news-2.csn.net>
  9. Reply-To: Barnett@interramp.com
  10. NNTP-Posting-Host: ip38.philadelphia.pa.interramp.com
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. Charles,
  14.  
  15. First the standard pointers; comp.os.ms-windows.programmer.win32 and
  16. possibly comp.os.ms-windows.programmer.tools.mfc are better places for
  17. questions of this nature.
  18.  
  19. charles stoyer <cstoyer@support.interpex.com> wrote:
  20.  
  21. >I have been working with Microsoft Developers Studio with C++ 
  22. >and Fortran 90 Powerstation for about two weeks or so now. I 
  23. >come from a purely FORTRAN/assembly language background but 
  24. >have been programming for over 25 years. I've gotten pretty far 
  25. >and have bypassed the "Hello world" project and created a nifty 
  26. >little dialog box application of my own, soon to be available 
  27. >on the web for free. The application takes geomagnetic models 
  28. >from the USGS and other world geomagnetic agencies and gives 
  29. >the earth's magnetic field at the entered location and date. A 
  30. >DOS version is available now at 
  31. >http://www.interpex.com/interpex/ and is called GEOMAGIX.
  32.  
  33. Thank You.  If I download it will it improve my C++ skills? :)
  34.  
  35. >I may be able to field some questions about getting Fortran to 
  36. >call and be called from C++, as I have done both. Will be able 
  37. >to be more useful as time goes on, I hope.
  38.  
  39. I think you mean to say that you will be able to field questions
  40. concerning MS PS Fortran & MS VC++ 4.0 static and run-time linking
  41. protocols? Most definitely in comp.os.ms-windows.programmer.win32 I
  42. trust?!
  43.  
  44. >It seems that support from compiler/system manufacturers has 
  45. >gone to the dogs and either they don't answer or they answer a 
  46. >different question than was asked.  So I guess we must turn to 
  47. >support groups like this.
  48.  
  49. Most likely NOT comp.lang.c++. Rather...
  50.  
  51. comp.os.ms-windows.nt
  52. comp.os.ms-windows.nt.pre-release
  53. comp.os.ms-windows.nt.software.backoffice
  54. comp.os.ms-windows.nt.software.compatibility
  55. comp.os.ms-windows.nt.programer.nt.kernel-mode
  56. comp.os.ms-windows.nt.programmer.tools.mfc
  57. comp.os.ms-windows.nt.programmer.win32
  58.  
  59. comp.os.ms-dos.programmer
  60. .
  61. .
  62. .
  63. comp.os.etc., etc. please check  your news group list more carefully.
  64. Also, consider searching  the MSDN Level 1.  Virtually every one of
  65. your questions is given comprehensive coverage there. Is that 'gone to
  66. the dogs' support?
  67.  
  68. >I have some questions which I have so far not been able to 
  69. >figure out. I have the MSDV CD ROM's, so answers could point me 
  70. >there or to the online documentation, if appropriate.
  71.  
  72. >1. What is a .PCH file and what is it for? It is huge (4Mb) 
  73. >even for small programs and exists in both the Release and 
  74. >Debug directories. I can't find any reference to it in the 
  75. >documentation. Do I need it and can I turn it off?
  76.  
  77. ... .PCH,  a.k.a., a pre-compiled header file. It will continue to
  78. grow unless you take steps to manage the build process by including
  79. the appropriate pre-processor directives. Please read under topic
  80. 'pre-compiled headers'.
  81.  
  82. ...Need? No.
  83. ...Turn it off? Yes. But all builds using MFC will take a
  84. significantly  longer time to complete. See 'Lean and Mean'
  85. VC_EXTRALEAN below. Flame... it is the price of progress.
  86.  
  87. One way of organizing your project to make it smaller and quicker to
  88. build might be...
  89.  
  90. In your application (or class)  .h
  91. // application class
  92. #ifndef __AFXWIN_H__
  93.     #error include 'stdafx.h' before including this file for PCH
  94. #endif
  95. Class GeoTerm        // etc.
  96. {};
  97. ...
  98.  
  99. In your application (or class) .cpp
  100. #include "stdafx.h"
  101. #include "applcation (or class) .h"     //here
  102. ...
  103.  
  104. In stdafx.h    // use the following
  105.  
  106. #define VC_EXTRALEAN        // To reduce the size of the *.PCH, etc.
  107. #include <afxwin.h>
  108.  
  109. etc.
  110.  
  111. >2. You can't call an item which expects a string or string 
  112. >pointer with a Cstring argument. Is there some way to copy to 
  113. >or recast as a Cstring to a string or string pointer? UPDATE: 
  114. >maybe I was doing something else wrong. Anyway, if you have 
  115. >comments on the difference between a string and a Cstring, I'd 
  116. >be interested.
  117.  
  118. Please peruse the on-line help for details. Topic CString::CString. In
  119. general the Win32 SDK run-time 'expects' a pointer to the traditional
  120. null terminated array of char for 'strings'. However many Win 32 SDK
  121. functions have MFC equivalents that do handle CString. The NT Win32
  122. SDK also provides for both multibyte (MBCS) and UNICODE 'strings' in
  123. addition to single byte ASCII but each requires its own set of _str
  124. functions and casts. This whole issue is MS platform specific. UNICODE
  125. is supported only on NT. MBCS is supported by both NT and Win95.
  126. Win/16 supports neither. Please see the docs on TCHAR for all the gory
  127. details. In the meantime you can keep the run-time happy and still use
  128. CString. The following assumes you are using the American Standard
  129. char datatype. On Windows that means a single byte, 8 bits per byte.
  130.  
  131. void MagneticWindows()
  132. {
  133. CString    WinClass;
  134. LPSTR    lpWinClass;
  135.  
  136. WinClass = "GeoApp";
  137.  
  138. // For times when a CString won't do.
  139.  
  140. lpWinClass = new char[WinClass.GetLength()+1];
  141.  
  142. if (!(lpWinClass == NULL)) {        //Best to write your own exception
  143.  strcpy(lpWinClass,WinClass);    //handler, standard speech.
  144. }
  145.  
  146. // Most Win SDK does not know about CString, so use...
  147.  ::MessageBox(0,lpWinClass,lpWinClass,MB_OK); 
  148.  
  149. //Most of the Afx, a.k.a. Application FrameWork Extended, a.k.a. MFC
  150. //does understand CString and provides overloaded functions for same.
  151.  
  152. AfxMessageBox(WinClass);        // no ref but works fine.
  153. AfxMessageBox(lpWinClass);    // works fine too. Ain't C++
  154. wonderful?
  155.  
  156. delete [] lpWinClass;        // don't forget. 
  157. }
  158.  
  159.  
  160. Some tips:
  161.  
  162. 1) Don't use CString unless you must.
  163.  
  164. 2) If you do use CString try to do so from the frame rather than the
  165. heap. CString memory management is virtually (pun intended)
  166. non-existant. It has many strange days.
  167.  
  168. >3. I loaded WIN32S from the new MSDN disk onto a machine 
  169. >running Windows 3.11, but there are a lot of libraries missing 
  170. >when I try to run my application., for example MSVCRT40.DLL, 
  171. >MFC40.DLL and the Fortran library MSFRT40.DLL. Should I be 
  172. >building my applications differently? Or is there another 
  173. >library I need to load? How can I let Win 3.1x users use my 
  174. >application? I tried linking a C++/Fortran app with no runtime 
  175. >(=DLL?) libraries, but I am calling AFXMesageBox and it didn't 
  176. >like that. NOTE THAT it seems that if you mix languages, if you 
  177. >DLL one you must DLL the other or you can't link.
  178.  
  179. This is VERY MS specific. First, read the distribution notes. Second,
  180. read the on-line help regarding project build options. Third there are
  181. problems (under specific circumstances) when intermixing the new MFC
  182. dlls with the older 2.0 versions. Also, there are limitations using
  183. MFC with Win32s. If possible avoid it. If not spend more time in
  184. comp.os.ms-windows.win32. Hint: Static Link. I know,  it hurts. You
  185. may run into more 'generic' problems with C++ name mangling. I am not
  186. familar with the latest version of MS Fortran. Maybe someone in
  187. comp.os.ms-windows.programmer.win32 will be able to help.
  188.  
  189. >4. MS claims that OpenGL is available only on Windows NT. Is 
  190. >that true? What about 3.1x?
  191. Yes. for WinNT 3.5 and up.
  192. No. for both WinNT 3.1 and Win/16 3.1
  193. ..and just in case you forgot to ask .No, WinNT does not support
  194. DirectX. Neither does Win/16.
  195.  
  196. >5. It looks like radio buttons are treated in a "dumb" fashion 
  197. >by the dialog resource editor and the AppWizard. It seems that 
  198. >it is the application's responsibility to see that one button 
  199. >is turned on and turn the others off before updating data. Is 
  200. >that right?
  201.  
  202. Yes. MFC is not an application painter or generator. It is a
  203. framework. Project Workbench Wizards only outline the application. You
  204. must still fill in the blanks. Think of it as a Template.  The $%@#$
  205. is in the details. The resource editor simply saves you the pain of
  206. typing all the gory details with your editor plus you get to 'paint'
  207. and 'see' what the widget will look like at runtime. If you want
  208. 'live' controls see VB or Delphi, or Envelop, or CA-Realizer, or
  209. PowerBuilder, etc. But sooner or later you will still need to code no
  210. matter which tool you select.
  211.  
  212. >6. Is there an easy way to add a standard system icon to a 
  213. >dialog box? For instance, the information icon or the warning 
  214. >icon, which seems to come with noises when used with 
  215. >AFXMessageBox and the UINT constant MB_ICONINFORMATION?
  216. Yes. read the help. See the samples. It is _very_ easy. The noises may
  217. be coming from an improper sound set up? See your control panel.
  218.  
  219. >Any answers anyone can give would be appreciated!
  220.  
  221. Well, I hope this helps. Charles, you need to spend some more time
  222. hitting the docs. You are not in Kansas anymore. Making the jump from
  223. plain old DOS to Windows is not easy. Trying to jump from FORTRAN to
  224. MSVC 32bit programming at the same time may be too long a stretch. Try
  225. concentrating on just C++.  MSVC allows you to build console apps
  226. quickly and easily. No MFC or GUI required! Just use getchar();
  227. anywhere you want to pause to see the results on stdout (printf, cout,
  228. etc)  and the console will pause, just like magic.
  229.  
  230. I look forward to seeing your posts on
  231. comp.os.ms-windows.programmer.win32 and
  232. comp.os.ms-windows.programmer.tools.mfc. Until Later...
  233.  
  234. >-- 
  235. >"You don't need a weatherman to know which way the wind blows" 
  236. >(B. Dylan)
  237.  
  238. >Charles Stoyer, Interpex Limited, Box 839, Golden CO 80401 USA
  239. >cstoyer@interpex.com, CompuServe: 75142.2356 
  240. >www/interpex.com/interpex/
  241.  
  242.  
  243.  
  244. -
  245. barnett@interramp.com
  246. -
  247.  
  248.